package usaco;
/*
ID:toregg1
LANG:JAVA
TASK:beads
 */

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

public class beads {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new FileReader("usaco/beads.in"));
		PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter("beads.out")));
		
		br.readLine();
		String beads = br.readLine().trim();
		beads = beads + beads;
		
		int[] rLeft = new int[beads.length()];
		int[] bLeft = new int[beads.length()];
		rLeft[0] = bLeft[0] = 0;
		
		for(int i = 0; i < beads.length() - 1; i++){
			if(beads.charAt(i) == 'r'){
				rLeft[i + 1] = rLeft[i] + 1;
				bLeft[i + 1] = 0;
			}else if(beads.charAt(i) == 'b'){
				rLeft[i + 1] = 0;
				bLeft[i + 1] = bLeft[i] + 1;
			}else{
				rLeft[i + 1] = rLeft[i] + 1;
				bLeft[i + 1] = bLeft[i] + 1; 
			}
		}
		
		int[] rRight = new int[beads.length() + 1];
		int[] bRight = new int[beads.length() + 1];
		rRight[beads.length()] = bRight[beads.length()] = 0;
		
		for(int i = beads.length() - 1; i > 0; i--){
			if(beads.charAt(i) == 'r'){
				rRight[i] = rRight[i + 1] + 1;
				bRight[i] = 0;
			}else if(beads.charAt(i) == 'b'){
				rRight[i] = 0;
				bRight[i] = bRight[i + 1] + 1;
			}else{
				rRight[i] = rRight[i + 1] + 1;
				bRight[i] = bRight[i + 1] + 1; 
			}
		}
		
		int longest = 0;
		for(int i = 0; i < beads.length(); i++){
			if(bLeft[i] + rRight[i] > longest){
				longest = bLeft[i] + rRight[i];
			}
		}
		for (int i = 0; i < beads.length(); i++) {
			if(rLeft[i] + bRight[i] > longest){
				longest = rLeft[i] + bRight[i];
			}
		}
		
		if(longest > beads.length() >> 1){
			longest = beads.length() >> 1;
		}
		
		System.out.println("bLeft:  " + arrToString(bLeft));
		System.out.println("rRight: " + arrToString(rRight));
		System.out.println("bRight: " + arrToString(bRight));
		System.out.println("rLeft:  " + arrToString(rLeft));
		
		pw.println(longest);
		pw.close();
		System.out.println(longest);
		System.exit(0);
	}
	private static String arrToString(int[] arr) {
		String str = "";
		for (int i = 0; i < arr.length; i++) {
			str = str + arr[i] + " ";
		}
		return str;
	}
}
